package eval.engine;

import com.google.inject.Inject;

import eval.deploy.IDemandManager;
import eval.deploy.IDeployManager;
import eval.engine.FireFighting.FireFightingEngine;
//import eval.engine.cplex.CplexPlacementEngine;
//import eval.engine.cplex.IDataModelGenerator;
import eval.engine.cplex.cplexEngine;
import eval.engine.openStack.OpenStackEngine;
import eval.host.IHostManager;
import eval.host.compare.ISortHostList;
import eval.hostEvaluate.IHostEvaluate;
import eval.vm.IVMManager;

public class PlacementEngineFactory implements IplacementEngineFactory {

	private IVMManager vmManager;
	private IDeployManager deployManager;
	private IHostManager hostManager;
	private IDemandManager demandManager;
	private IHostEvaluate hostEvaluator;
	private ISortHostList sortHostList;


	@Inject
	public PlacementEngineFactory(IVMManager vmManager,
			IDeployManager deployManager, IHostManager hostManager,
			IDemandManager demandManager,ISortHostList sortHostList,
			IHostEvaluate hostEvaluator) {
		this.vmManager = vmManager;
		this.deployManager = deployManager;
		this.hostManager = hostManager;
		this.demandManager = demandManager;
		this.sortHostList = sortHostList;
		this.hostEvaluator = hostEvaluator;

	}

	public IPlacementEngine createNewEngine(String engineStr) {

		OptimizationGoalEnum engine = OptimizationGoalEnum.valueOf(engineStr);

		switch (engine) {

		case OPEN_STACK:
			return new OpenStackEngine(vmManager, deployManager, hostManager, demandManager,
					sortHostList, hostEvaluator);
		case CPLEX:
			return new cplexEngine(vmManager, deployManager, hostManager, demandManager,
					sortHostList, hostEvaluator);
			
		case FIRE_FIGHTING:
			return new FireFightingEngine(vmManager, deployManager, hostManager, demandManager,
					sortHostList, hostEvaluator);
		default:
			throw new IllegalArgumentException("Invalid placement engine");
		
		}
	}
}
